import java.util.*;

public class DarrTest {
    static public Scanner sc = new Scanner(System.in);

    static public void main(String [] args) {
        int num, count = 0;
        int [] a = null;
        int [] prev = null;

        while (true) {
            System.out.printf("请输入整型(-1为退出): ");
            num = sc.nextInt();
            if (num == -1)
                break;

            a = new int[count + 1];
            if (prev != null)
                System.arraycopy(prev, 0, a, 0, count);
            a[count] = num;
            prev = a;

            count++;
        }

        // 在之打印刚才用户输入的所有数
        for (int i : a) {
            System.out.printf("%d ", i);
        }
        System.out.println();
    }
}
